﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace DefLib
{
    public class ViewFrame
    {
        public static bool Lock = true;
        public static Rectangle window = new Rectangle(0, 0, gDef.Window.ClientBounds.Width, gDef.Window.ClientBounds.Height);

        public static void reset()
        {
            window = new Rectangle(0, 0, gDef.Window.ClientBounds.Width, gDef.Window.ClientBounds.Height);
        }
        public static void update(Point p_pos )
        {
            if(!Lock)
            {
                p_pos.X -= window.X;
                p_pos.Y -= window.Y;
              /*  if (p_pos.X < window.X)
                    window.X += (p_pos.X -window.X);

                int x_temp = p_pos.X - window.Width;
                if (x_temp > window.X)
                    window.X += (x_temp - window.X);

                if (p_pos.Y < window.Y)
                    window.Y += (p_pos.Y - window.Y);

                int y_temp = p_pos.Y - window.Height;
                if (y_temp > window.Y)
                    window.Y += (y_temp - window.Y);
                */
                if (p_pos.X < 0)
                    window.X += p_pos.X/5;

                int x_temp = p_pos.X -window.Width;
                if (x_temp > 0)
                    window.X += x_temp/5;


                if (p_pos.Y < 0)
                    window.Y += p_pos.Y/5;

                int y_temp = p_pos.Y - window.Height;
                if (y_temp > 0)
                    window.Y += y_temp/5;
            }
        }
    }
}
